package com.test.thread.example03;

public class ThreadState {

    public static void main(String[] args) {
        // 创建一个线程
        Thread thread = new Thread(() -> {
            // 任务代码
            System.out.println("线程执行任务");
        });
        System.out.println("线程状态: " + thread.getState());
        // 启动线程
        thread.start();

        try {
            // 等待线程执行完成
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        // 获取线程状态并打印
        Thread.State state = thread.getState();
        System.out.println("线程状态: " + state); // TERMINATED
    }
}
